NB IoT
api.nbSend(addr, port, msg, timeout, type)
- Overview
- Arguments
- Example
Sends buffer msg to NB on specified IP, port and protocol type. Maximum length of Rx and Tx messages is 512 Bytes. Maximum execution time is limited by timeout milliseconds.
- addr (string) - IP address
- port (integer) - Port
- msg (string) - String to be sent to NB
- timeout (integer) - The maximum execution time in milliseconds
- type (string) - Protocol type, either UDP or TCP.
-- sends "test message" string to IP 185.8.239.192 on port 5566 with 6s timeout
status,answer = api.nbSend("185.8.239.192", 5566, "test message", 6000, "UDP")
-- sends buffer to IP and port specified in GUI with 6s timeout
buf, err, proto, wake, ip, port, ctx = api.getGUIContext()
status,answer = api.nbSend(ip, port, "test message", 6000, proto)
api.nbAT(command, timeout, wakeUp)
- Overview
- Arguments
- Return
- Example #1
- Example #2
- Example #3
Sends an AT command to NB module with specified timeout.
- command (string) - AT command
- timeout (integer) - The maximum execution time in milliseconds
- wakeUp (integer, optional) - Sending 1 will make sure that module is not asleep
- answer (string) - Nil or non-zero length string with an answer to a AT command
- status (integer) - Zero for success, negative for failure
-- Get IMSI number of SIM card with timeout of 4 seconds
res = api.nbAT("AT+CIMI", 4000)
print(res)
-- IMEI --
x=api.nbAT("AT+CGSN")
start = string.find(x, "\n")
finish = string.find(x, "\r", start+1)
imei = string.sub(x,(start+1),(finish-1))
print("IMEI: " .. imei)
-- Get signal strength
res,b = api.nbAT("AT+CSQ")
print(res)